<template>
  <view class="base-info-card">
    <view class="enterprise-name-status">
      <text class="enterprise-name">
        {{ enterpriseInfo?.enterpriseName }}
      </text>
      <text class="register-status">
        {{ enterpriseInfo.registerStatus }}
      </text>
     <!-- <text class="share" @tap="handleShareBtnClick">
        分享
      </text> -->
    </view>
    <view class="info-cell-group">
      <view class="info-cell">
        <view class="info-cell__left">
          <text class="label">
            信用代码：
          </text>
          <text class="value">
            {{ enterpriseInfo.scCode }}
          </text>
        </view>
        <view class="info-cell__right">
          <text class="btn-copy" @tap="copyText(enterpriseInfo.scCode) ">
            复制
          </text>
        </view>
      </view>
      <view class="info-cell">
        <view class="info-cell__left">
          <text class="label">
            联系电话：
          </text>
          <text class="value">
            {{ enterpriseInfo.phone }}
          </text>
        </view>
      </view>
      <view class="info-cell">
        <view class="info-cell__left">
          <text class="label">
            注册地址： {{ enterpriseInfo.address }}
          </text>
        </view>
      </view>
    </view>
    <view class="btn-group" v-if="bottomButtons.length > 0">
      <view class="btn" v-for="(btn, index) in bottomButtons" :key="index"
      @tap="handleBtnClick(btn)">
        {{ btn.btnText }}
      </view>
    </view>
  </view>
</template>
<script setup>
import { defineProps, defineEmits } from 'vue'
const props = defineProps({
  enterpriseInfo: {
    type: Object,
    default: {}
  },
  bottomButtons: {
    type: Array,
    default: []
  }
})
function copyText(text) {
  uni.setClipboardData({
    data: text,
    success: function () {
      console.log('复制成功');
      // 可以添加用户友好的提示，例如使用uni.showToast提示复制成功
      uni.showToast({
        title: '复制成功',
        icon: 'success',
        duration: 2000
      });
    },
    fail: function () {
      console.log('复制失败');
      // 可以添加错误处理或用户友好的提示
    }
  });
}
const emits = defineEmits(['bottomBtnClickEmit'])

const handleBtnClick = btn => {
  emits('bottomBtnClickEmit', btn)
}

const handleShareBtnClick = () => {
  console.log('分享')
}
</script>
<style scoped lang=less>
.base-info-card {
  width: 731rpx;
  min-height: 344rpx;
  border-radius: 33rpx;
  box-shadow: 0 5rpx 13rpx 1rpx rgba(0,0,0,.05);
  padding: 31rpx 31rpx 43rpx 24rpx;
  margin: 0 auto ;
  box-sizing: border-box;
  background-color: @color-origin-white;
  font-family: 'ali-p';
  margin-bottom: 50rpx;
  .enterprise-name-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15rpx;
    .enterprise-name {
      font-weight: 500;
      font-size: 31rpx;
      color: @color-black-text;
    }
    .register-status,
    .share{
      width: 67rpx;
      height: 30rpx;
      background-color: @color-green;
      border-radius: 3rpx;
      color: @color-origin-white;
      font-size: 20rpx;
      text-align: center;
      margin-left: 28rpx;
    }
    .share {
      background-color: @color-blue;
    }
  }
  .info-cell {
    display: flex;
    justify-content: space-between;
    margin-bottom: 19rpx;
    &__left {
      font-size: 23rpx;
      line-height: 47rpx;
      .label {
        color: @color-light-grey-text;
      }
      .value {
        color: @color-blue-text;
      }
    }
    &__right {
      .btn-copy {
        display: inline-block;
        width: 65rpx;
        height: 36rpx;
        background-color: @color-white-btn;
        font-size: 23rpx;
        color: @color-grey-text;
        text-align: center;
      }
    }
  }
  .btn-group {
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    .btn {
      height: 35rpx;
      line-height: 35rpx;
      background-color: @color-white-btn;
      font-size: 23rpx;
      color: @color-blue-text;
      margin-right: 13rpx;
    }
  }
}
</style>
